// get user info
import { addAddress, page } from '@/api/cart'
import { getOrdersInfo } from '@/api/order'

const actions = {
  // 这里是get选中商品信息
  getCart({ commit }, data) {
    return new Promise((resolve, reject) => {
      page(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  addAddress({ commit }, data) {
    return new Promise((resolve, reject) => {
      addAddress(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  },
  getOrders({ commit }, data) {
    return new Promise((resolve, reject) => {
      getOrdersInfo(data).then(response => {
        resolve(response)
      }).catch(error => {
        reject(error)
      })
    })
  }
}

export default {
  namespaced: true,
  actions
}
